package com.pearadmin.pro.modules.policy.rest;

import com.pearadmin.pro.modules.policy.domain.ScrmStuPrePolicy;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.policy.domain.ScrmStuPrePolicy;
import  com.pearadmin.pro.modules.policy.param.ScrmStuPrePolicyRequest;
import  com.pearadmin.pro.modules.policy.service.ScrmStuPrePolicyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 签单优惠政策Controller
 *
 * @author chenJian
 * @date 2021-10-07
 */
@Api(tags = {"签单优惠政策"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"policy/stuPrePolicy")
public class ScrmStuPrePolicyController extends BaseController
{
    @Resource
    private ScrmStuPrePolicyService scrmStuPrePolicyService;

    /**
     * 查询签单优惠政策列表
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "签单优惠政策列表")
    @ApiOperation(value = "签单优惠政策列表")
    public Result<ScrmStuPrePolicy> list(ScrmStuPrePolicyRequest scrmStuPrePolicyRequest)
    {
        return success(scrmStuPrePolicyService.page(scrmStuPrePolicyRequest));
    }


    /**
     * 新增保存签单优惠政策
     * @param scrmStuPrePolicy 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增签单优惠政策")
    @ApiOperation(value = "新增签单优惠政策")
    public Result save(@RequestBody ScrmStuPrePolicy scrmStuPrePolicy)
    {
        return auto(scrmStuPrePolicyService.saveOrUpdate(scrmStuPrePolicy));
    }

    /**
     * 查询签单优惠政策详情
     *
     * @param id 签单优惠政策ID
     * @return 签单优惠政策
     */
    @GetMapping("/selectById")
    @Log(title = "查询签单优惠政策详情")
    @ApiOperation(value = "查询签单优惠政策详情")
    public Result<ScrmStuPrePolicy> selectById(@RequestParam Long id)
    {
        return success(scrmStuPrePolicyService.selectScrmStuPrePolicyById(id));
    }



    /**
     * 修改保存签单优惠政策
     * @param scrmStuPrePolicy 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改签单优惠政策")
    @ApiOperation(value = "修改签单优惠政策")
    public Result update(@RequestBody ScrmStuPrePolicy scrmStuPrePolicy)
    {
        return auto(scrmStuPrePolicyService.saveOrUpdate(scrmStuPrePolicy));
    }


    /**
     * 删除保存签单优惠政策
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除签单优惠政策")
    @ApiOperation(value = "删除签单优惠政策")
    public Result remove(@RequestParam Long id)
    {
        return auto(scrmStuPrePolicyService.removeById(id));
    }

    /**
    * 批量删除签单优惠政策
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除签单优惠政策")
    @ApiOperation(value = "批量删除签单优惠政策")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(scrmStuPrePolicyService.removeByIds(ids));
    }

}
